USE [WarehouseManagement]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		duylv00360
-- Create date: 
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[DO_GetDeletedMaterialOrder] 
	-- Add the parameters for the stored procedure here
	@OrderId int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SELECT	ml.MaterialID MaterialID,
			ml.WarehouseID WarehouseID,
			ml.Quantity Quantity,
			ml.PricePerUnit PricePerUnit
	FROM	MaterialLoaf ml
	WHERE	ml.OrderID = @OrderId
	UNION
	SELECT	pl.ProductID MaterialID,
			pl.WarehouseID WarehouseID,
			pl.Quantity Quantity,
			pl.PricePerUnit PricePerUnit			
	FROM	ProductLoaf pl
	WHERE	pl.OrderID = @OrderId
    
END

GO

/*
use WarehouseManagement
go
exec GetDeletedMaterialOrder 138
*/
